//
//  AppRecommendedPopView.m
//  markmap
//
//  Created by 甘世清 on 2024/10/13.
//

#import "AppRecommendedPopView.h"

@implementation AppRecommendedPopView

- (void)SQ_UIViewForSelfView{
    self.backgroundColor = UIColor.clearColor;
    self.headerView = [[HeaderView alloc]init];
    self.headerView.headerImage.contentMode = UIViewContentModeScaleAspectFit;
    [self addSubview:self.headerView];
    [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
    }];
    [self.headerView.btn addTarget:self action:@selector(SQ_buttonClick) forControlEvents:UIControlEventTouchUpInside];
    [self SQ_header];
}
-(void)SQ_header{
    NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
    [dic setObject:@"app_recommended" forKey:@"key"];
    [HttpTool post:Url52 paramDic:dic successBlock:^(BaseModel * _Nonnull httpModel) {
        self.jsonData = [[NSMutableDictionary alloc]initWithDictionary:httpModel.data];
        NSString * value = [self.jsonData objectForKey:@"value"];
        NSDictionary * valueDic = [value mj_JSONObject];
        [self.headerView.headerImage sd_setImageWithURL:SQURLImage([valueDic objectForKey:@"imageUrl"])];
    } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
        
    }];
}
-(void)SQ_buttonClick{
    NSString * value = [self.jsonData objectForKey:@"value"];
    NSDictionary * valueDic = [value mj_JSONObject];
    NSString *str = [NSString stringWithFormat:@"%@",[valueDic objectForKey:@"url"]];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{} completionHandler:^(BOOL success) {
    }];
}

@end
